﻿<UserControl x:Class="DocumentManagement.Views.ShowItemDocumentInUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:vm="clr-namespace:DocumentManagement.ViewsModels"
             mc:Ignorable="d" 
             d:DesignHeight="768" d:DesignWidth="1024" Background="#5D90EF0F" xmlns:my="clr-namespace:DocumentManagement.Converters" Loaded="UserControl_Loaded">
    <UserControl.Resources>
        <vm:ShowItemDocumentInViewsModel x:Key="showItemDocumentInViewsModel"/>
        <my:DateConverter x:Key="dateConverter" />
        <my:TextSpeedConverter x:Key="textSpeedConverter" />
        <my:TextActionConverter x:Key="textActionConverter" />
        <ContextMenu x:Key="MyContextMenu">
            <MenuItem Header="เพิ่มหนังสือเข้า" Name="addINDocMenu" Click="addINDocMenu_Click" />
            <MenuItem Header="แก้ไขหนังสือเข้า" Name="editINDocMenu" Click="editINDocMenu_Click" />
            <MenuItem Header="ลบหนังสือเข้า" Name="deleteINDocMenu" Click="deleteINDocMenu_Click" />
        </ContextMenu>
        <my:TextStatusConverter x:Key="textStatusConverter" />
       
    </UserControl.Resources>
    <Grid>
        <Grid DataContext="{Binding Source={StaticResource showItemDocumentInViewsModel}}" Margin="10,10,12,29" >
            <Grid.RowDefinitions>
                <RowDefinition Height="35" />
                <RowDefinition Height="30" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>

            <StackPanel Height="35" Name="stackPanel2" Orientation="Horizontal" VerticalAlignment="Center" >
                <TextBlock FontSize="16" Height="23" Margin="0,5,0,0" Name="textBlock2" Text="ค้นหาข้อมูลหนังสือเข้า" TextAlignment="Center" VerticalAlignment="Center" Width="195" FontFamily="Tahoma" FontWeight="Bold" />
            </StackPanel>

            <StackPanel Height="30" Name="stackPanel3" Orientation="Horizontal" Grid.Row="1" >
                <TextBlock FontSize="14" Height="23" Name="textBlock4" Text="เลขที่หนังสือ/ชื่อเรื่อง :" TextAlignment="Right" Width="150" FontFamily="Tahoma" FontWeight="Normal" />
                <TextBox FontSize="14" Height="23" KeyUp="ReceiveCodeOrTitleTextBox_KeyUp" Margin="10,0,0,0" Name="ReceiveCodeOrTitleTextBox" Width="298" Text="{Binding Path=MyFilter, Mode=TwoWay}" FontFamily="Tahoma" FontWeight="Normal" />
                <TextBlock FontSize="14" Height="21" Name="textBlock6" Text="จากวันที่ :" TextAlignment="Right" Width="80" FontFamily="Tahoma" FontWeight="Normal" />
                <DatePicker FontSize="14" Height="28" Margin="10,0,0,0" Name="FromDatePicker" SelectedDateChanged="FromDatePicker_SelectedDateChanged" Width="115" FontFamily="Tahoma" FontWeight="Normal" />
                <TextBlock FontSize="14" Height="21" Name="textBlock7" Text="ถึงวันที่ :" TextAlignment="Right" Width="80" FontFamily="Tahoma" FontWeight="Normal" />
                <DatePicker FontSize="14" Height="28" Margin="10,0,0,0" Name="ToDatePicker" SelectedDateChanged="ToDatePicker_SelectedDateChanged" Width="115" FontFamily="Tahoma" FontWeight="Normal" />
            </StackPanel>

            <DataGrid Grid.Row="2"  AutoGenerateColumns="False"  FontSize="14" ItemsSource="{Binding Path=MyReceiveICV, Mode=TwoWay}" Name="ShowReceiveDataGrid" ContextMenu="{StaticResource MyContextMenu}" SelectedItem="{Binding Path=MySelectedEditItemReceive, Mode=TwoWay}" CanUserSortColumns="True" CanUserResizeRows="True" CanUserResizeColumns="True" CanUserReorderColumns="True" IsManipulationEnabled="False" IsReadOnly="True" Margin="0,5,0,0" AlternatingRowBackground="#5D90EF0F" FontFamily="Tahoma" FontWeight="Normal">
                <DataGrid.Columns>
                    <DataGridTextColumn Binding="{Binding Path=ReceiveID, Mode=TwoWay}" Header="รหัส" />
                    <DataGridTextColumn Binding="{Binding Path=ReceiveCode, Mode=TwoWay}" Header="รหัสรับหนังสือ" />
                    <DataGridTextColumn Binding="{Binding Path=ReceiveDate, Mode=TwoWay, StringFormat=\{0:d\}, Converter={StaticResource dateConverter}}" Header="วันที่รับหนังสือ" />
                    <DataGridTextColumn Binding="{Binding Path=DocumentDate, Mode=TwoWay, StringFormat=\{0:d\}, Converter={StaticResource dateConverter}}" Header="วันที่ในหนังสือ" />
                    <DataGridTextColumn Binding="{Binding Path=DocumentCode, Mode=TwoWay}" Header="เลขที่ในหนังสือรับ" />

                    <!--<DataGridTemplateColumn Header="ไฟล์หนังสือเข้า">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <ListBox ItemsSource="{Binding Path=ReceiveAttachedFiles}">
                                            <ListBox.ItemTemplate>
                                                <DataTemplate>
                                                    
                                                    <StackPanel Orientation="Horizontal">
                                                        <TextBlock Text="{Binding Path=FileName}"/>
                                                        <Button Content="Download"/>
                                                    </StackPanel>
                                                </DataTemplate>
                                            </ListBox.ItemTemplate>
                                        </ListBox>
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>-->
                    <DataGridTextColumn Binding="{Binding Path=Division_FromDivision.ThaiName, Mode=TwoWay}" Header="จากหน่วยงาน" />
                    <DataGridTextColumn Binding="{Binding Path=Division_ToDivision.ThaiName, Mode=TwoWay}" Header="ถึงหน่วยงาน" />


                    <!--<DataGridHyperlinkColumn Binding="{Binding Path=Title, Mode=TwoWay}" Header="ชื่อเรื่อง" >
                            </DataGridHyperlinkColumn>-->
                    <DataGridHyperlinkColumn Binding="{Binding Path=Title, Mode=TwoWay}" Header="ชื่อเรื่อง">
                        <DataGridHyperlinkColumn.ElementStyle>
                            <Style>
                                <EventSetter Event="Hyperlink.Click" Handler="DG_Hyperlink_Click"/>
                            </Style>
                        </DataGridHyperlinkColumn.ElementStyle>
                    </DataGridHyperlinkColumn>
                    <!--<DataGridTextColumn.ElementStyle>
                        <Style TargetType="{x:Type TextBlock}">
                            <Setter Property="Background" Value="{Binding Name, Converter={StaticResource NameToBrushConverter}}"/>
                        </Style>
                    </DataGridTextColumn.ElementStyle>-->
                    <DataGridTextColumn Binding="{Binding Path=Speed, Mode=TwoWay, Converter={StaticResource textSpeedConverter}}" Header="ชั้นความเร็ว" >
                        <DataGridTextColumn.ElementStyle>
                            <Style TargetType="{x:Type TextBlock}">
                                <Style.Triggers>
                                    <Trigger Property="Text" Value="ปกติ">
                                        <Setter Property="Foreground" Value="Black"/>
                                    </Trigger>
                                    <Trigger Property="Text" Value="ด่วน" >
                                        <Setter Property="Foreground" Value="Red"/>
                                    </Trigger>
                                    <Trigger Property="Text" Value="ด่วนมาก">
                                        <Setter Property="Foreground" Value="Red"/>
                                    </Trigger>
                                    <Trigger Property="Text" Value="ด่วนที่สุด">
                                        <Setter Property="Foreground" Value="Red"/>
                                    </Trigger>
                                </Style.Triggers>
                                
                            </Style>
                        </DataGridTextColumn.ElementStyle>
                    </DataGridTextColumn>
                    <DataGridTextColumn Binding="{Binding Path=Action, Mode=TwoWay, Converter={StaticResource textActionConverter}}" Header="การปฏิบัติ" />
                    <DataGridTextColumn Binding="{Binding Path=Description, Mode=TwoWay}" Header="หมายเหตุ" />
                    <DataGridTextColumn Binding="{Binding Path=Type, Mode=TwoWay, Converter={StaticResource textStatusConverter}}" Header="ชนิดหนังสือ" />
                    <DataGridTextColumn Binding="{Binding Path=LogID, Mode=TwoWay}" Header="ผู้บันทึกรายการ" />

                    <!--<DataGridTemplateColumn Header="ดาวน์โหลดไฟล์">
                              
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate >
                                        <Button Content="ดาวน์โหลด" Height="23" Name="DownloadButton" Width="75" Click="DownloadButton_Click" />
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>-->
                </DataGrid.Columns>
            </DataGrid>

        </Grid>
    </Grid>
</UserControl>
